package com.wd.serverjni;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author long
 * @date 2013-4-27 下午4:25:52
 * @qq 108232706
 * @description ServerJniMgr
 */
public class ServerJniMgr {

	static {
		System.out.println(System.getProperty("java.library.path"));
		System.loadLibrary("serverjni");
		System.out.println("加载serverjni完成 !");
	}

	public static void main(String[] args) {
		System.out.println("Hello ServerJniMgr!");
//		receive(new byte[20]);
		System.out.println("ready call native send(bytes[])");
		send(new byte[20]);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println("=======ServerJniMgr over==============");
	}

	/**
	 * java发数据给c++
	 * 
	 * @param bytes
	 */
	public static native void send(byte[] bytes);

	/**
	 * c++发数据给java
	 * 
	 * @param bytes
	 */
	public static void receive(byte[] bytes) {

		StringBuilder strTmp = new StringBuilder("收到数据,长度:" + bytes.length
				+ ";内容:");
		for (int i = 0; i < bytes.length; i++) {
			strTmp.append(i + ":" + bytes[i] + " ");
		}
		System.out.println(strTmp.toString());
	}

	public static class testtest {
		int[] i0;
		byte b1;
		int i1;
		float f0;
		double f1;
		boolean b0;
		float f3;
		char[] str;

		public testtest() {
			i0 = new int[10];
			b1 = 0;
			str = new char[20];
		}
	}
	
	
	static long first;
	static long second;
	public static void start() {
		first = System.currentTimeMillis();
		System.out.println("start ms:" + first);
	}

	public static void stop() {
		second = System.currentTimeMillis();
		System.out.println("stop ms:" + second);
		System.out.println("cost ms:" + (second - first));
	}

}
